#ifndef SCRIBBLEAREA_H
 #define SCRIBBLEAREA_H

 #include <QColor>
 #include <QImage>
 #include <QPoint>
 #include <QWidget>
 #include <QRect>
 #include <QTreeWidget>

 //class QTreeWidget;

#include "zone.h"

 class ScribbleArea : public QWidget
 {
     Q_OBJECT

 public:
     ScribbleArea(QWidget *parent = 0);
    //~ScribbleArea();

     bool openImage(const QString &fileName);
     bool saveImage(const QString &fileName, const char *fileFormat);
     void setPenColor(const QColor &newColor);
     void setPenWidth(int newWidth);

     //the xml stuff here
     bool generateZoneXml(const QString &fileName);
     bool loadZoneXml(const QString &fileName);

     bool isModified() const { return modified; }
     QColor penColor() const { return myPenColor; }
     int penWidth() const { return myPenWidth; }

 public slots:
     void clearImage();
     void print();
     void getProperties();

 private slots:
     // these are for the zone options here
     void addPolicyGui();
     void editPolicy();
     void removeZone();
     void resetZone();
 protected:
     void contextMenuEvent(QContextMenuEvent *event);
     void mousePressEvent(QMouseEvent *event);
     //void mouseMoveEvent(QMouseEvent *event);
     void mouseReleaseEvent(QMouseEvent *event);
     void paintEvent(QPaintEvent *event);
     void resizeEvent(QResizeEvent *event);

 private:
     void drawLineTo(const QPoint &endPoint);
     void resizeImage(QImage *image, const QSize &newSize);
     void createActions();
     bool fileOperation(int);
     void produceZoneTree(const QList<Zone> &temp_rectList,QTreeWidget *qw);
     
     bool modified;
     bool scribbling;
     int myPenWidth;
     QColor myPenColor;
     QImage image;
     QPoint lastPoint;
     QPoint rigthClickPoint;
     Zone qrectemp;
     QList <Zone> rectList;

     //the right click menu options
     QAction *getPropertiesAct;
     QAction *addPolicyAct;
     QAction *editPolicyAct;
     QAction *removeZoneAct;
     QAction *resetZoneAct;
     QString loadFileName; // The screen shot
     int menuRectIndex;
     bool validZoneMenu;
     bool validRemoveZone;

 };

 #endif
